**************************************************************************************************
*** This do file creates the replication results for 
*** On the Detrimental Impact of Visa Restrictions on Bilateral Trade and					 	*/
*** Foreign Direct Investment																	*/
*** 																							*/
*** Eric Neumayer (LSE)																			*/
*** Published in: Applied Geography, 2012														*/
**************************************************************************************************
**************************************************************************************************
/* Note: 
You have to change "local DIR" to the directory you copy the original stata files contained 	*/
/* in the zip file and then run the do file. 													*/
**************************************************************************************************

version 11.0
drop _all
clear matrix
clear mata
set mem 800m
set mat 5000

capture net install outreg2, from(http://fmwww.bc.edu/RePEc/bocode/o)			/* checks whether outreg2 is installed 		*/

***********************************************************************************
local DIR = "C:\Research\Development finance\Busse\"  /*change relative path to the directory where the files are located */
cd "`DIR'"
***********************************************************************************

use "Article for Applied Geography (visa).dta", clear

** Table 1
xi: reg  lntrade  lndistw contiguity4dummy sameregion coloniallinkplusrussia rta comlang   diplomatic_rep_sum lnmigrantstock_sum   dyad_onevisa dyad_bothvisa i.country1 i.country2, robust
outreg2 using table1, replace excel 2aster
test 2*dyad_onevisa =dyad_bothvisa
*** Note: The estat command allows you to see the covariance matrix, drop the star before the command line to activate
* estat vce

xi: heckman  lntrade  lndistw contiguity4dummy sameregion coloniallinkplusrussia rta comlang   diplomatic_rep_sum lnmigrantstock_sum   dyad_onevisa dyad_bothvisa i.country1 i.country2, select(lndistw contiguity4dummy sameregion coloniallinkplusrussia rta comlang   diplomatic_rep_sum lnmigrantstock_sum   dyad_onevisa dyad_bothvisa i.country1 i.country2) vce(robust)
outreg2 using table1, append excel 2aster
*** Note: The mfx command takes a long time to run, drop the star before the command line to activate
* mfx    compute, pred(yc) varlist(dyad_onevisa dyad_bothvisa contiguity4dummy)

xi: reg  lnfdistock lndistw contiguity4dummy sameregion coloniallinkplusrussia rta comlang   diplomatic_rep_sum lnmigrantstock_sum  bitordtt dyad_onevisa dyad_bothvisa  i.country1 i.country2 , robust
outreg2 using table1, append excel 2aster
test 2*dyad_onevisa =dyad_bothvisa
*** Note: The estat command allows you to see the covariance matrix, drop the star before the command line to activate
* estat vce

xi: heckman   lnfdistock lndistw contiguity4dummy sameregion coloniallinkplusrussia rta comlang   diplomatic_rep_sum lnmigrantstock_sum  bitordtt   dyad_onevisa dyad_bothvisa i.country1 i.country2, select(lndistw contiguity4dummy sameregion coloniallinkplusrussia rta comlang   diplomatic_rep_sum lnmigrantstock_sum   bitordtt  dyad_onevisa dyad_bothvisa i.country1 i.country2) vce(robust)
outreg2 using table1, append excel 2aster
*** Note: The mfx command takes a long time to run, drop the star before the command line to activate
* mfx    compute, pred(yc) varlist(dyad_onevisa dyad_bothvisa)


*** Robustness checks & extensions
* Dummy variables for political regime type in both countries included
xi: reg  lntrade  lndistw contiguity4dummy sameregion coloniallinkplusrussia rta comlang   diplomatic_rep_sum lnmigrantstock_sum   dyad_onevisa dyad_bothvisa  freedomhouse_bothdem freedomhouse_bothautoc i.country1 i.country2, robust
xi: reg  lnfdistock lndistw contiguity4dummy sameregion coloniallinkplusrussia rta comlang   diplomatic_rep_sum lnmigrantstock_sum  bitordtt dyad_onevisa dyad_bothvisa  freedomhouse_bothdem freedomhouse_bothautoc  i.country1 i.country2, robust

* Absolute GDPpc difference included
xi: reg  lntrade lndistw contiguity4dummy sameregion coloniallinkplusrussia rta comlang   diplomatic_rep_sum lnmigrantstock_sum   dyad_onevisa dyad_bothvisa   abs_gdppcconst_diff  i.country1 i.country2, robust
xi: reg  lnfdistock lndistw contiguity4dummy sameregion coloniallinkplusrussia rta comlang   diplomatic_rep_sum lnmigrantstock_sum  bitordtt dyad_onevisa dyad_bothvisa abs_gdppcconst_diff  i.country1 i.country2 , robust

* Log of absolute GDPpc difference included
xi: reg  lntrade lndistw contiguity4dummy sameregion coloniallinkplusrussia rta comlang   diplomatic_rep_sum lnmigrantstock_sum   dyad_onevisa dyad_bothvisa   lnabs_gdppcconst_diff  i.country1 i.country2, robust
xi: reg  lnfdistock  lndistw contiguity4dummy sameregion coloniallinkplusrussia rta comlang   diplomatic_rep_sum lnmigrantstock_sum  bitordtt dyad_onevisa dyad_bothvisa lnabs_gdppcconst_diff   i.country1 i.country2 , robust

* Different effects on trade in developing country dyads as opposed to other dyads
xi: reg  lntrade  lndistw contiguity4dummy sameregion coloniallinkplusrussia rta comlang   diplomatic_rep_sum lnmigrantstock_sum    dyad_onevisa_developingdyad dyad_onevisa_nondevelopingdyad dyad_bothvisa_developingdyad dyad_bothvisa_nondevelopingdyad i.country1 i.country2, robust
test  dyad_bothvisa_developingdyad= dyad_bothvisa_nondevelopingdyad
test  dyad_onevisa_developingdyad= dyad_onevisa_nondevelopingdyad

